package com.qust.enDecrpytion.looPool;

import lombok.Data;
import lombok.extern.log4j.Log4j2;

import java.util.ArrayList;
import java.util.Stack;

@Log4j2
@Data
public abstract class AbstractLooPool<T> implements LooPool<T>{
    protected ArrayList<Node<T>> nodes;
    protected Stack<Node<T>> stack;
    protected int nOfCore;
    protected int nOfMax;
    protected int nOfOther;


    public AbstractLooPool(int nOfCore ,int nOfMax){
        this.nOfMax = nOfMax;
        this.nOfCore = nOfCore;
        nodes = new ArrayList<>(nOfCore);
        stack = new Stack<>();
    }

    @Override
    public void addNode(T node) {
        Node<T> tNode = new Node<>(node,stack);
        nodes.add(tNode);
        stack.push(tNode);
    }

    @Override
    public void remove(Node<T> node) {
        nodes.remove(node);
    }

    @Override
    public abstract Node<T> getIdleNode();
}
